clear
set matsize 5000
cd <directory>
**********************************************************************************************************************
** Takes the raw temprature monitors' data and cleans them 
**********************************************************************************************************************


foreach i of numlist 23{
import excel "Unit`i'_indoor_until10aug2015.xls", sheet("Worksheet") cellrange(A3) firstrow clear
g unit=`i'
g datetemp=substr( Timezone,1,10)
g date=date(datetemp, "YMD")
format date %td
tempfile indoor`i'
save `indoor`i''

import excel "Unit`i'_outdoor_until10aug2015.xls", sheet("Worksheet") cellrange(A3) firstrow clear
cap drop E
g datetemp=substr( Timezone,1,10)
g date=date(datetemp, "YMD")
format date %td
foreach var of varlist Temperature Humidity{
ren `var' Outdoor`var'
}
merge 1:1 date using `indoor`i''
keep if _merge==3
tempfile unit`i'
save `unit`i''
}

foreach i of numlist 10 12{
import excel "Unit`i'_indoor_until10aug2015.xls", sheet("Worksheet") cellrange(A3) firstrow clear
g unit=`i'
g datetemp=substr( Timezone,1,10)
g date=date(datetemp, "YMD")
format date %td
tempfile indoor`i'
save `indoor`i''

import excel "Unit`i'_outdoor_until13aug2015.xls", sheet("Worksheet") cellrange(A3) firstrow clear
cap drop E
g datetemp=substr( Timezone,1,10)
g date=date(datetemp, "YMD")
format date %td
foreach var of varlist Temperature Humidity{
ren `var' Outdoor`var'
}
merge 1:1 date using `indoor`i''
keep if _merge==3
tempfile unit`i'
save `unit`i''
}

use `unit10', clear
append using `unit12'
append using `unit23'

save "netatmo_u10and12and23_until10aug2015", replace
